package com.gomore.opple.module.addcustomer;

import android.os.Bundle;

import com.gomore.opple.R;
import com.gomore.opple.module.BaseActivity;
import com.gomore.opple.module.IntentStart;
import com.gomore.opple.web.cgform.consumer.entity.TOConsumerEntity;

import javax.inject.Inject;

/**
 * Created by asus on 2017/5/9.
 */
public class AddCustomerActivity extends BaseActivity {
    @Inject
    AddConsumerPresenter addConsumerPresenter;

    private AddConsumerFragment addConsumerFragment;
    private TOConsumerEntity toConsumerEntity;

    @Override
    protected void initalizeViewData() {
        super.initalizeViewData();
        if (getIntent() != null) {
            toConsumerEntity = (TOConsumerEntity) getIntent().getSerializableExtra(IntentStart.CONSUMER);
        }
    }

    @Override
    protected void initalizeViews() {
        if (addConsumerFragment == null) {
            addConsumerFragment = AddConsumerFragment.getInstance();
            Bundle bundle = new Bundle();
            bundle.putSerializable(IntentStart.CONSUMER, toConsumerEntity);
            addConsumerFragment.setArguments(bundle);
            replaceFragment(addConsumerFragment, false, "add_consumer_view");
        }
    }

    @Override
    protected void initializeDependencyInjector() {
        DaggerAddConsumerComponent.builder()
                .dataRepositoryComponent(getRepositoryComponent())
                .addConsumerPresenterModule((new AddConsumerPresenterModule(addConsumerFragment)))
                .build()
                .inject(this);
    }

    @Override
    protected int getLayoutView() {
        return R.layout.activity_add_consumer;
    }

}
